package com.example.user.user

import android.util.SparseArray
import androidx.activity.viewModels
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.library_base.base.BaseActivity
import com.example.library_base.router.UserRouterPath
import com.example.user.BR
import com.example.user.R
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
@Route(path = UserRouterPath.USER_USER)
class UserActivity: BaseActivity(R.layout.activity_user) {

//    private val mViewModel by viewModels<UserViewModel> { SavedStateViewModelFactory(application, this) }
    private val mViewModel by viewModels<UserViewModel>()

    @Inject
    lateinit var eventHandler: UserEventHandler

    override fun getVariableSparseArray(): SparseArray<Any> {
        val variables = SparseArray<Any>()
        variables.put(BR.userViewModel, mViewModel)
        variables.put(BR.event, eventHandler)
        return variables
    }

    override fun initTitleBar() {

    }

    override fun requestData() {
        mViewModel.getData()
    }

    override fun initView() {
        val testModel = UserModel();
        testModel.name = "初始化数据"
        mViewModel.setModelLiveData(testModel)
    }
}